<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加优惠券</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/Application/iframe/assets/libs/layuiadmin/layui/css/layui.css"/>
    <link rel="stylesheet" href="/Application/iframe/assets/libs/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="/Application/iframe/assets/libs/layuiadmin/style/mylay.css" media="all">
    <style type="text/css">
        html {background: #fff;padding-top: 20px;}
    </style>
</head>
<body>
<div class="layui-form">
    <input type="hidden" id="m_shop" name="m_shop" lay-verify="required" placeholder="商铺ID" value="{$id}" autocomplete="off" class="layui-input">
    <input type="hidden" id="m_uid" name="m_uid" lay-verify="required" placeholder="uID" value="{$uid}" autocomplete="off" class="layui-input">
    <div class="layui-form-item">
        <label class="layui-form-label"><span>*</span> 优惠券名称</label>
        <div class="layui-input-inline">
            <input type="text" name="m_title" lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">例如: 满xxx减xx元</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">购物券类型</label>
        <div class="layui-input-inline">
            <select name="m_type" lay-filter="m_type">
                <option value="{$couponType.id}">{$couponType.name}</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span>*</span> 图片</label>
        <div class="layui-input-inline">
            <input type="text" id="m_pic" name="m_pic" lay-verify="required" placeholder="请上传图片" autocomplete="off" class="layui-input">
        </div>
        <button class="layui-btn" type="button" id="btn_upload">上传</button>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><span>*</span>满减金额</label>
            <div class="layui-form-mid"> 满</div>
            <div class="layui-input-inline" style="width: 100px;">
                <input type="number" name="m_max" lay-verify="required|number" placeholder="￥" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid"> 减</div>
            <div class="layui-input-inline" style="width: 100px;">
                <input type="number" name="m_min" lay-verify="required|number" placeholder="￥" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span>*</span> 优惠券数量</label>
        <div class="layui-input-inline">
            <input type="number" name="m_quota" lay-verify="required|number" placeholder="请输入数量" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">例如: 20</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">发放时间</label>
        <div class="layui-input-inline">
            <input type="text" name="m_fa_time" class="layui-input" lay-verify="required" id="test16" placeholder="开始 到 结束" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> 已领取数量</label>
        <div class="layui-input-inline">
            <input type="number" name="m_take" lay-verify="required" value="0" autocomplete="off" class="layui-input" disabled="disabled">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> 已使用数量</label>
        <div class="layui-input-inline">
            <input type="number" name="m_used" lay-verify="required" value="0" autocomplete="off" class="layui-input" disabled="disabled">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注/说明</label>
        <div class="layui-input-block">
            <textarea name="m_bz" placeholder="请输入内容" lay-verify="required" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">添加时间</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" lay-verify="required" name="m_time" value="{$time}" placeholder="年-月-日 时:分:秒" disabled="disabled">
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-submit" id="LAY-submit" value="确认">
    </div>
</div>

<script type="text/javascript" src="/Application/iframe/assets/libs/layuiadmin/layui/layui.js"></script>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#test16'
            ,type: 'datetime'
            ,range: ','

        });
    });
    layui.config({
        base: '/Application/iframe/assets/libs/layuiadmin/'
    }).extend({
        index: 'lib/index'
    }).use(['index', 'form', 'upload'], function(){
        var $ = layui.$
            ,upload = layui.upload
            ,form = layui.form;
        //上传
        upload.render({
            elem: '#btn_upload'
            ,url: "{:U('upload/uploadFile')}"
            ,data: {dir: 'coupon'}
            ,accept: 'images'
            ,before: function () {
                layer.load();
            }
            ,done: function(res){
                layer.closeAll();
                if(res.code == 1001) {
                    $('#m_pic').val(res.file);
                    $('#yl_pic').attr('src',res.src);
                }
                else {
                    layer.msg(res.msg);
                }
            }
            ,error: function(){
                layer.closeAll();
                layer.msg('请求异常');
            }
        });

    })

</script>
</body>
</html>